<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.global.js"></script>
    <style>
        .active {
            text-decoration: underline;
        }

        .text-danger {
            color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- div是否有active这个class取决于isActive是否为true -->
        <div :class="{ active: isActive }">令妹啊</div>

        <div class="static" :class="{ active: isActive, 'text-danger': hasError }">
            令妹啊
        </div>

        <div :class="classObject">令尊</div>

        <div :class="[activeClass, errorClass]">令堂</div>

        <div :class="[{ active: isActive }, errorClass]">令郎</div>


    </div>

    <script>
        const app = {
            data() {
                return {
                    isActive: false,
                    hasError: false,
                    classObject: {
                        active: false,
                        'text-danger': undefined
                    },
                    activeClass: 'active',
                    errorClass: 'text-danger'
                }
            }
        }
        Vue.createApp(app).mount("#app")
    </script>
</body>

</html>